try{
require('./dragloader.js')
}catch(e){

}
var dragger;
export default{loadMore: function (targetClass, downFn, upFn , moreClass) {
    var cssStr = "line-height:80px;font-size:0.3rem;color:#333333;height:100%;background:white;text-align:center";
     dragger = new DragLoader(document.getElementsByClassName(targetClass)[0], {
        dragDownRegionCls: 'latest',
        dragUpRegionCls: moreClass || 'more',
        disableDragDown: !downFn,
        disableDragUp: !upFn,
        dragDownHelper: function (status) {
    // var cssStrDown = "position:fixed;width:100%;background:white;z-index:10000000;line-height:80px;font-size:3rem;color:#333333;height:80px;background:white;text-align:center";
            if (status == 'default') {
                if ($(".down-default").length) { $(".down-default").parent().remove() }
                return '<div style=' + cssStr + ' class="down-default">向下拉加载最新</div>';
            } else if (status == 'prepare') {
                return '<div style=' + cssStr + '  class="down-prepare">释放刷新</div>';
            } else if (status == 'load') {
                return '<div style=' + cssStr + '  class="down-load">加载中...</div>';
            }
        },
        dragUpHelper: function (status) {
            if (status == 'default') {
                if ($(".up-default").length) { $(".up-default").parent().remove() }
                return '<div style=' + cssStr + '  class="up-default">向上拉加载更多</div>';
            } else if (status == 'prepare') {
                return '<div style=' + cssStr + '  class="up-prepare">释放刷新</div>';
            } else if (status == 'load') {
                return '<div style=' + cssStr + '  class="up-load">加载中...</div>';
            }
        }
    });
    dragger.on('dragDownLoad', function () {
        downFn();
        setTimeout(function () {
            dragger.reset();
        }, 200);
    });
    dragger.on('dragUpLoad', function () {
        upFn();
        setTimeout(function () {
            dragger.reset();
        }, 200);
    });
},
rmLoadMore:function(targetClass){
    if(dragger){
    dragger.setDragDownDisabled(true);
    dragger.setDragUpDisabled(true);
    }
}
}